#include <iostream>
#include <vector>
using namespace std;
void shift(vector<int>& arr) { 
  int tmp = arr.back();
  int l = arr.size();
  arr.erase(arr.begin() + l - 1);
  arr.insert(arr.begin(), tmp);
  return; 
}
int main() {
  int n;
  cin >> n;
  vector<int> arr_p;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    arr_p.push_back(x);
  }
  // for (auto& x : arr_p) {
  //     cout << x << " ";
  //   }
  //   cout << endl;
  do {
    shift(arr_p);
    for (auto& x : arr_p) {
      cout << x << " ";
    }
    cout << endl;
  } while (arr_p.back() != n);
  return 0;
}